/** 
Copyright (c) 2010, Sheikh Abdul Wahid Ahmed
Details @ http://extremecodeworld.codeplex.com/license
**/

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Reflection;
using System.IO;
using EXtremecode.Utils;
using System.Text;
namespace CodeGenerator
{
	/// <summary>
	/// Summary description for Test.
	/// </summary>
	public class Test : System.Windows.Forms.Form
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		public static string str="Ali";
		public Test()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			// 
			// Test
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(392, 262);
			this.Name = "Test";
			this.Text = "Test";
			this.Load += new System.EventHandler(this.Test_Load);

		}
		#endregion

		[STAThread]
		static void Main(string[] args)
		{
			Application.Run(new Test());
		}

		private void Test_Load(object sender, System.EventArgs e)
		{
		
			//test entity definition
			string encryptedData = EXtremecode.Utils.DataEncryptor.Instance.GetEncryptedString("Abdul Wahid");
			string decryptedData = EXtremecode.Utils.DataEncryptor.Instance.GetDecryptedString(encryptedData);
			
			str="Abdul Wahid";
			StringBuilder generatedCode=FileUtil.ReadFileData(@"d:\temp\c.cs");
			StringBuilder currentCode=FileUtil.ReadFileData(@"d:\temp\d.cs");
			Managers.CustomCodeExchangeManager.Instance.ExchangeCustomCode(generatedCode,currentCode);

			Definitions.SessionCollection col=new CodeGenerator.Definitions.SessionCollection();
			col.LoadSessions(@"d:\temp\b.cs");
			Console.WriteLine(col["a"].Method);
			Managers.GeneratingCodeManager.CreateInstance(col);
			string strsss=Managers.GeneratingCodeManager.Instance.GetSessionResult("a");
			Debugging.Debug.VerifyExpression();
			//Debugging.Debug.ShowText(strsss);

			Assembly assembly=AssemblyCreator.CreateAssembly(@"d:\temp\mysample.cs",null,@"mysample.dll");
			Type clsType = assembly.GetType("mynamespace.Sample");
			object instance=Activator.CreateInstance(clsType);
			MethodInfo methodinf = clsType.GetMethod("ShowHello");
			methodinf.Invoke(instance, null);
			Console.WriteLine(str);
			

		}
	}

	
}
